package top.laoliu.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import top.laoliu.pojo.PositionResume;
import top.laoliu.service.DeliveryService;

/**
 * @Author: acer
 * @Date: 2020/10/17 14:13
 * @Description:
 */
@RequestMapping("/delivery")
@Controller
public class DeliveryController {
    @Autowired
    private DeliveryService deliveryService;

    @RequestMapping("/getDeliveryCount")
    @ResponseBody
    public int getDeliveryCount(Integer user_id){
        return deliveryService.getDeliveryCount(user_id);
    }

    @RequestMapping("/confirmDelivery")
    @ResponseBody
    public String confirmDelivery(Integer position_id,Integer user_id){
        Integer deliveryStatus = deliveryService.getDeliveryStatus(new PositionResume(position_id, user_id, null, 1));

        System.out.println(deliveryStatus);
        if (deliveryStatus==null){
            int isDeliverySuccess = deliveryService.insertDelivery(new PositionResume(position_id, user_id, null, 1));
            System.out.println(isDeliverySuccess);
            if (isDeliverySuccess>0){
                return "true";
            }
        }
        return "false";
    }
}
